const express = require("express");
const app = express();


// 允许跨域
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By", ' 3.2.1')
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});

const data = [
    {id: 1, checked: false, title: "好吃的汉堡1", price: 12},
    {id: 2, checked: false, title: "好吃的汉堡2", price: 55},
    {id: 3, checked: false, title: "好吃的汉堡3", price: 62},
    {id: 4, checked: false, title: "好吃的汉堡4", price: 84},
    {id: 5, checked: false, title: "好吃的汉堡5", price: 25},
    {id: 6, checked: false, title: "好吃的汉堡6", price: 39},
    {id: 7, checked: false, title: "好吃的汉堡7", price: 13},
    {id: 8, checked: false, title: "好吃的汉堡8", price: 27},
    {id: 9, checked: false, title: "好吃的汉堡9", price: 19},
]

app.get("/data", (req, res) => {
    res.json(data);
});
app.listen("3000", () => {
    console.log("run at 3000")
});